package com.dianjing.dianjing.service.impl;

import com.dianjing.dianjing.dto.input.TestInput;
import com.dianjing.dianjing.entity.TestEntity;
import com.dianjing.dianjing.mapper.TestMapper;
import com.dianjing.dianjing.service.TestService;
import com.dianjing.dianjing.util.DataUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author liangbaigao
 * @Date 2022/11/7 14:44
 */
@Service
public class TestServiceImpl implements TestService {

    @Resource
    private TestMapper testMapper;
    /**
     * @return
     */
    @Override
    public DataUtils getDta() {
        return DataUtils.ok(testMapper.selectAll());
    }

    /**
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public DataUtils insertData(TestInput input) {
        testMapper.insert(new TestEntity(input.getTest()));
        return DataUtils.ok("插入成功");
    }
}
